package com.zglc.ms.shop.dao;

import com.zglc.ms.shop.model.PointRuleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * PriceRuleDao
 * <p>
 * </p>
 *
 * @author Vigor Yuan
 */
@Repository
public class PointRuleDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<PointRuleVo> findAll() {
        String sql = "SELECT rule_id,rule_name FROM point_rule";
        return  this.jdbcTemplate.query(sql, (rs, rowNum) -> {
            PointRuleVo pointRuleVo = new PointRuleVo();
            pointRuleVo.setId(rs.getInt("rule_id"));
            pointRuleVo.setRuleName(rs.getString("rule_name"));
            return pointRuleVo;
        });
    }
}
